<?php

   require("../../configuracion.php");
   $idSysSection = $sectionCampCorreo;
   $path = "../../";
   require("../../application-top.php");
   $id_CampaniaCP = $_GET['id_CampaniaCP'];
   
   
    $query = "select ";
    $query .= " st_NombreCampaniaCP, st_ContenidoCampaniaCP, ";
    $query .= " st_RemitenteCampaniaCP, st_MonitorCampania, ";
    $query .= " DAY(dt_FechaAlta) as diaAlta, MONTH(dt_FechaAlta) as mesAlta, YEAR(dt_FechaAlta) as anoAlta, ";
    $query .= " st_StatusCampania, st_DescCampaniaCP, st_RemitenteCampaniaCP, ";
    $query .= " ltrim(app_SysUsers.nombre) + ' ' + ltrim(app_SysUsers.paterno) + ' ' + ltrim(app_SysUsers.materno) as Elaboro, ";
    $query .= " tbl_SegmentosCRM.id_Segmento, tbl_SegmentosCRM.st_Segmento ";
    $query .= " from tbl_CampaniasCorreoPostal ";
    $query .= " INNER JOIN cat_StatusCampania ON tbl_CampaniasCorreoPostal.id_StatusCampania = cat_StatusCampania.id_StatusCampania ";
    $query .= " INNER JOIN app_SysUsers ON tbl_CampaniasCorreoPostal.id_UsuarioAlta = app_SysUsers.id_SysUser ";
    $query .= " LEFT JOIN tbl_SegmentosCRM ON tbl_CampaniasCorreoPostal.id_Segmento = tbl_SegmentosCRM.id_Segmento ";
    $query .= " where tbl_CampaniasCorreoPostal.id_CampaniaCorreoPostal = '" . $id_CampaniaCP . "' ";

    $result = mssql_query ($query);
    $row = mssql_fetch_object($result);


    $FechaAlta = "";
      if ($row->diaAlta <> "")
      {
        if(strlen($row->diaAlta)<2)
        {
          $row->diaAlta = "0".$row->diaAlta;
        }

        if(strlen($row->mesAlta)<2)
        {
          $row->mesAlta = "0".$row->mesAlta;
        }
      
        $FechaAlta = $row->diaAlta . "/" . $row->mesAlta . "/" . $row->anoAlta;
      }

?>
<html>
<head>
  <title><?= $instanciaECRM ?></title>
  <link rel="stylesheet" href="../../styles/style.css" type="text/css">
  <script type="text/javascript" src="../../scripts/dynlayer.js"></script>
</head>
<body leftmargin="0" class="mainBackground" topmargin="0" marginwidth="0" marginheight="0">
<table width="100" border="0" cellpadding="0" cellspacing="0">
  <tr><td><img src="../../images/headerBar.gif" width="590" height="60" alt=""></td></tr>
  <tr>
    <td><table width="800" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td bgcolor="#FFFFFF" valign="top" height="400">
<form name="forma">
<script type="text/javascript">
<!--
  function Eliminar() {
    if (confirm('Esta seguro que desea eliminar la campa&ntilde;a de \'<?= $row->st_NombreCampaniaCP ?>\'')) {
      window.open('correo_delete.php?url=correo_admin.php&id_CampaniaCP=<?= $id_CampaniaCP ?>','content');
    }
  }
  
//-->
</script>
<table border="0" cellpadding="5" cellspacing="0" width="750">
  <tr><td colspan="2"><table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr><td colspan="2"><img src="images/spacer.gif" height="10" width="1" alt=""></td></tr><tr><td><strong class="pageTitle">Campa&ntilde;as Correo Postal</strong><br><strong class="pageSubtitle">Detalle Campa&ntilde;a Correo Postal</strong></td><td align="right"><a href="http://www.cacto.com/" target="_blank"><img src="../../images/trademarkCacto.gif" alt="Cacto" border="0"></a><br>
<strong class="systemTitle"><?= $instanciaECRM ?></strong><br>Perfil <strong><?= $PerfilUsuario ?></strong></td></tr>
  </table></td></tr>
  <tr><td>
    <table border="0" cellpadding="5" cellspacing="1" class="mainTableBG">
      <tr class="answerCellBG">
        <td><img src="../../images/icArrowGo.gif" height="13" width="13" alt=""></td>
        <td><a href="correo_admin.php" target="content">Regresar</a></td>
      </tr>
    </table>
  </td></tr>
  <tr>
  <td valign="top" width="100%">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr><td>
        <table border="0" cellpadding="0" cellspacing="0" width="100%">
        <tr><td colspan="2">
        <table border="0" cellpadding="5" cellspacing="1" class="secTableBG">

    
          <tr class="mainTableBG"><td class="secTableTitle" colspan="2">Correo&nbsp;Postal&nbsp;<strong><?= $row->st_NombreCampaniaCP ?></strong></td></tr>
		 <tr class="answerCellBG"><td width="110" class="conceptCellBG" colspan="2"><strong>Configuraci&oacute;n</strong></td></tr>
          <tr class="answerCellBG"><td width="110" valign="top" class="conceptCellBG">Descripci&oacute;n de la Campa&ntilde;a:</td><td><?= $row->st_DescCampaniaCP ?></td></tr>
          <tr class="answerCellBG"><td width="110" class="conceptCellBG">Status:</td><td><?= $row->st_StatusCampania ?></td></tr>
          <tr class="answerCellBG"><td width="110" class="conceptCellBG">Monitor de la campa&ntilde;a:</td><td><?= $row->st_MonitorCampania ?></td></tr>
          <tr class="answerCellBG"><td width="110" class="conceptCellBG">Elaborado por:</td><td><?= $row->Elaboro ?></td></tr>
          <tr class="answerCellBG"><td width="110" class="conceptCellBG">Fecha&nbsp;de&nbsp;Alta:</td><td><?= $FechaAlta ?></td></tr>
		 <tr class="answerCellBG"><td width="110" class="conceptCellBG" colspan="2"><strong>Mensaje</strong></td></tr>
		 <tr class="answerCellBG"><td width="110"  class="conceptCellBG">De (Remitente de la Campa&ntilde;a):</td><td><?= $row->st_RemitenteCampaniaCP ?></td></tr>
		 <tr class="answerCellBG"><td width="110" class="conceptCellBG">Para:</td><td><?=  html_entity_decode(urldecode($row->st_Segmento)) ?></td></tr>
          <tr class="answerCellBG"><td width="110" valign="top" class="conceptCellBG">Contenido (Pieza):</td><td><?= $row->st_ContenidoCampaniaCP ?></td></tr>
		 <tr class="answerCellBG"><td width="110" class="conceptCellBG" colspan="2"><strong>Resultados</strong></td></tr>
		 <?
		 $queryRes  = "select sum(i_Enviados) as enviados, count(*) as envios ";
		 $queryRes .= " FROM tbl_CampaniasCorreoPostalEnviadas ";
		 $queryRes .= " WHERE (id_CampaniaCorreoPostal = '".$id_CampaniaCP."'); ";
	    $resRes = mssql_query ($queryRes);
    $rowRes = mssql_fetch_object($resRes);
		 ?>
		 
		 <tr class="answerCellBG"><td width="110"  class="conceptCellBG">Envios:</td><td><?=number_format($rowRes->envios) ?> ejecuciones (envios)</td></tr>
		 <tr class="answerCellBG"><td width="110"  class="conceptCellBG">Enviados:</td><td><?=number_format($rowRes->enviados) ?> <?= $row->st_NombreCampaniaCP ?> a <?=$Audiencias1 ?></td></tr>
     
     
     
     
        </table>
        </td></tr>
        <tr><td><img src="../../images/spacer.gif" height="10" width="1" alt=""></td></tr>
        </table>
      </td></tr>
      <tr><td><img src="../../images/spacer.gif" height="10" width="1" alt=""></td></tr>
      <tr><td>
        <table border="0" cellpadding="5" cellspacing="1" class="mainTableBG">
          <tr class="answerCellBG">
		  <? if ($rowRes->envios > 0) { ?>
            <td><img src="../../images/icArrowGo.gif" height="13" width="13" alt=""></td>
            <td><a href="correo_reporteenvios.php?id_CampaniaCP=<?= $id_CampaniaCP ?>" target="content">Reporte Env&iacute;o Correo</a></td>
		  <? } ?>	
            <td><img src="../../images/icArrowGo.gif" height="13" width="13" alt=""></td>
            <td><a href="correo_edit.php?id_CampaniaCP=<?= $id_CampaniaCP ?>" target="content">Modificar</a></td>
            <td><img src="../../images/icArrowGo.gif" height="13" width="13" alt=""></td>
            <td><a href="javascript:Eliminar()">Eliminar</a></td>
            <td><img src="../../images/icArrowGo.gif" height="13" width="13" alt=""></td>
            <td><a href="correo_retroalimentacion.php?id_CampaniaCP=<?= $id_CampaniaCP ?>" target="content">Retroalimentar</a></td>
          </tr>
        </table>
      </td></tr>
    </table>
  </td>
  </tr>
</table>
          </td>
        </tr>
      </table></td>
  </tr>
</table>
</form>
<br>
<br>
<br>
<table width="750" border="0" cellpadding="5" cellspacing="0">
  <tr>
    <td align="right"><span class="copyright"><?= $copyright ?></span></td>
  </tr>
</table>
</body></html>
